﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TVDL4
{
    public partial class frmMain : Form
    {
        

        public frmMain()
        {
            InitializeComponent();
        }

      
        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void itemVatLieu_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Form childForm = GetForm("frmVatLieu");
            if (childForm == null)
            {
                childForm = new frmVatLieu();
                childForm.MdiParent = this;
                childForm.Show();
                childForm.WindowState = FormWindowState.Normal;
                frmVatLieu tem = (frmVatLieu)childForm;
                tem.btnThem_Click(null, null);
               
            }
            else
            {
                childForm.Activate();
            }
            Cursor.Current = Cursors.Default;
        }
        private Form GetForm(String FormName)
        {
            foreach (Form f in this.FindForm().MdiChildren)
            {
                if (f.Name == FormName)
                    return f;
            }
            return null;
        }

        private void itemThiNghiem_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Form childForm = GetForm("frmThiNghiem");
            if (childForm == null)
            {
                childForm = new frmThiNghiem();
                childForm.MdiParent = this;
                childForm.Show();
                childForm.WindowState = FormWindowState.Normal;
                frmThiNghiem tem = (frmThiNghiem)childForm;
                tem.btnThem_Click(null, null);
                
            }
            else
            {
                childForm.Activate();
            }
            Cursor.Current = Cursors.Default;
        }

        private void itemMauVatLieu_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Form childForm = GetForm("frmMauVatLieu");
            if (childForm == null)
            {
                childForm = new frmMauVatLieu();
                childForm.MdiParent = this;
                childForm.Show();
                childForm.WindowState = FormWindowState.Normal;
                frmMauVatLieu tem = (frmMauVatLieu)childForm;
                tem.btnThem_Click(null, null);
            }
            else
            {
                childForm.Activate();
            }
            Cursor.Current = Cursors.Default;
        }

        private void ShowNewForm(object sender, EventArgs e)
        {

        }

        private void itemCongTrinh_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Form childForm = GetForm("frmCongTrinh");
            if (childForm == null)
            {
                childForm = new frmCongTrinh();
                childForm.MdiParent = this;
                //childForm.WindowState = FormWindowState.Maximized;
                childForm.Show();
                frmCongTrinh tem = (frmCongTrinh)childForm;
                tem.btnThem_Click(null, null);
               
            }
            else
            {
                childForm.Activate();
            }
            Cursor.Current = Cursors.Default;
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Form childForm = GetForm("frmGiaiDoan");
            if (childForm == null)
            {
                childForm = new frmGiaiDoan();
                childForm.MdiParent = this;
                childForm.WindowState = FormWindowState.Maximized;
                childForm.Show();
                frmGiaiDoan tem = (frmGiaiDoan)childForm;
                tem.btnThem_Click(null, null);
 
            }
            else
            {
                childForm.Activate();
                
            }
            Cursor.Current = Cursors.Default;
        }

        private void printToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            Form childForm = GetForm("FrmTimGiaiDoan");
            if (childForm == null)
            {
                childForm = new FrmTimGiaiDoan();
                childForm.MdiParent = this;
                childForm.WindowState = FormWindowState.Maximized;
                childForm.Show();

            }
            else
            {
                childForm.Activate();
            }
            Cursor.Current = Cursors.Default;

            
        }

        private void newToolStripButton_Click(object sender, EventArgs e)
        {
            toolStripMenuItem1_Click(null, null);
        }

        private void openToolStripButton_Click(object sender, EventArgs e)
        {
            printToolStripMenuItem_Click(null, null);
        }

       

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            toolStripMenuItem1_Click(null, null);
        }

       
        private void toolStripButton2_Click_1(object sender, EventArgs e)
        {
            printToolStripMenuItem_Click(null, null);
        }
    }
}
